package cn.gxufe.reliable.message.admin.lock;

import org.apache.commons.lang.StringUtils;

import java.net.InetAddress;

/**
 * @author yingjie.rong
 **/
public class InstanceInfo {

    private String uuid;
    private String hostname;
    public InstanceInfo(){}

    public InstanceInfo(String uuid){
        this.uuid = uuid;
        try {
            hostname = InetAddress.getLocalHost().getHostName();
        }catch (Exception e){

        }
    }

    public String getUuid() {
        return uuid;
    }

    public void setUuid(String uuid) {
        this.uuid = uuid;
    }

    public String getHostname() {
        return hostname;
    }

    public void setHostname(String hostname) {
        this.hostname = hostname;
    }

    @Override
    public boolean equals(Object obj) {
        if( obj == null ||  !(obj instanceof InstanceInfo)){
            return false;
        }
        return StringUtils.equals(((InstanceInfo)obj).getUuid(),this.uuid);
    }
}
